package com.qf.work20250104;

import java.sql.*;

/**
 * @author zdl
 * @date 2025/1/4
 */
public class Demo1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb1_2?useSSL=false", "root", "123456");
        Statement statement = conn.createStatement();
        ResultSet rs = statement.executeQuery("select * from tb_user");
        while (rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("username");
            String pwd = rs.getString("password");
            String phone = rs.getString("phone");
            Date create_time = rs.getDate("create_time");
            double money = rs.getDouble("money");
            int sex = rs.getInt("sex");
            User user = new User(id, name, pwd, phone, create_time, money, sex);
            System.out.println(user);
        }
    }
}
